﻿<UserControl x:Name="TagEditControl" x:Class="NicoView.View.NicoViewNiconicoTagEditControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             xmlns:converter="clr-namespace:NicoView.View.Converter"
             xmlns:Behaviors="clr-namespace:NicoView.View.Behaviors"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    

    <Grid>
        <ListView IsTabStop="False"  IsSynchronizedWithCurrentItem="True"  KeyboardNavigation.TabNavigation="Continue"  x:Name="TagListView"  HorizontalContentAlignment="Stretch"  BorderThickness="0" ItemsSource="{Binding Tags}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"  Margin="1" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}"  >

            
            <i:Interaction.Triggers>
                
                
                
                <ei:PropertyChangedTrigger Binding="{Binding}"   >
                    <Behaviors:BroadcastTagBottomAction />
                    
                </ei:PropertyChangedTrigger>
                



                

            </i:Interaction.Triggers>

            <ListView.ItemContainerStyle>
                <Style TargetType="{x:Type ListViewItem}">
                    <Style.Setters>
                        <Setter Property="IsSelected" Value="False"/>
                        <Setter Property="IsTabStop" Value="False"/>
                    </Style.Setters>
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.ItemTemplate>
                <DataTemplate>

                    <Grid >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition  Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>


                                <TextBox  MinWidth="30"  x:Name="TagEdit" Text="{Binding TagName,UpdateSourceTrigger=PropertyChanged}"  Grid.Column="0" SelectionBrush="{x:Null}"  Background="{x:Null}"  >
                                    
                                    <i:Interaction.Triggers>
                                        <ei:PropertyChangedTrigger Binding="{Binding TagName.Count}">
                                            
                                            <Behaviors:TagEditAction TargetObject="{Binding}" TargetTags="{Binding DataContext.Tags, ElementName=TagEditControl}"  />
                                            
                                        </ei:PropertyChangedTrigger>

                                       
                                        <i:EventTrigger EventName="LostFocus">
                                            <Behaviors:EmptyTagRemoveAction TargetObject="{Binding}" TargetTags="{Binding DataContext.Tags, ElementName=TagEditControl}" />
                                        </i:EventTrigger>
                                       
                                    </i:Interaction.Triggers>

                                </TextBox>
                                



                        <CheckBox x:Name="TagLockCheckBox"  VerticalAlignment="Center" IsChecked="{Binding IsLocked}" Grid.Column="1" Content="{Binding Lock, Mode=OneWay, Source={StaticResource resources}}" IsTabStop="False">
                            <CheckBox.Style>
                                <Style TargetType="{x:Type CheckBox}">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding TagName.Length}" Value="0">
                                            <Setter Property="Visibility" Value="Hidden"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </CheckBox.Style>

                        </CheckBox>

                    </Grid>


                </DataTemplate>
             </ListView.ItemTemplate>
        </ListView >
    </Grid>
</UserControl>
